package step

import (
	_interface "adam2/internal/quant/interface"
)

// 卖出步骤
type SellStep struct {
	commonSell            *_interface.Sell
	commonDelistSell      *_interface.Sell
	commonResolveFailSell *_interface.Sell
	sellDate              *_interface.SellDate
}

// 初始化
func (s *SellStep) Init(commonSell *_interface.Sell, commonDelistSell *_interface.Sell, commonResolveFailSell *_interface.Sell, sellDate *_interface.SellDate) {
	s.commonSell = commonSell
	s.commonDelistSell = commonDelistSell
	s.commonResolveFailSell = commonResolveFailSell
	s.sellDate = sellDate
}

// 执行
func (s *SellStep) Exec(transactionDate string) {
	(*s.commonResolveFailSell).DoSell(transactionDate)
	(*s.commonDelistSell).DoSell(transactionDate)

	if (*s.sellDate).IsSellDate(transactionDate) {
		(*s.commonSell).DoSell(transactionDate)
	}
}
